package com.example.cardview

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.SeekBar
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        sb_one.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
                card_view.radius = progress.toFloat()
            }

            override fun onStartTrackingTouch(seekBar: SeekBar?) {
                ToastUtil.showShort(this@MainActivity, "设置圆角onStartTrackingTouch")
            }

            override fun onStopTrackingTouch(seekBar: SeekBar?) {
                ToastUtil.showShort(this@MainActivity, "设置圆角onStopTrackingTouch")
            }
        })

        sb_two.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
            override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
                card_view.cardElevation = progress.toFloat()
            }

            override fun onStartTrackingTouch(seekBar: SeekBar?) {
                ToastUtil.showShort(this@MainActivity, "设置阴影onStartTrackingTouch")
            }

            override fun onStopTrackingTouch(seekBar: SeekBar?) {
                ToastUtil.showShort(this@MainActivity, "设置阴影onStopTrackingTouch")
            }

        })
        sb_three.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
            override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
                card_view.setContentPadding(progress, progress, progress, progress)
            }

            override fun onStartTrackingTouch(seekBar: SeekBar?) {
                ToastUtil.showShort(this@MainActivity, "设置间距onStartTrackingTouch")
            }

            override fun onStopTrackingTouch(seekBar: SeekBar?) {
                ToastUtil.showShort(this@MainActivity, "设置间距onStopTrackingTouch")
            }

        })
    }
    
}
